package cn.xdd.fileter;

import org.apache.log4j.Logger;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author user_xdd
 * @Date 2022-04-15 12:44
 * @description
 * @return
 */
//@WebFilter(urlPatterns = {"/*"})
public class ErroFileter implements Filter {
        private static  final Logger LOGGER = Logger.getLogger(ErroFileter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request  = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        request.setCharacterEncoding("utf-8");//设置请求中文编码
        response.setContentType("text/html;charset=utf-8");//设置响应中文编码

         LOGGER.debug("    response.getStatus();:"+response.getStatus());

         filterChain.doFilter(request, response);

    }

    @Override
    public void destroy() {

    }
}
